test(router): cover popstate handler propagation - #75
Merged
Conversation
The existing Navigation tests mocked window.addEventListener as a vi.fn() that captured the handler but never fired it — so nothing verified that browser back/forward actually flowed through to the pathname signal and its subscribers. Add three tests: - popstate updates pathname signal (basic mechanism). - popstate propagates to a .changes subscriber (drives Outlet reconcile). - popstate handler's Effect.runSync doesn't throw or fail silently. Updated the mock window's addEventListener to store the handler so it can be dispatched via a new dispatchWindowEvent helper. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deploying effex with
|
| Latest commit: |
1c29ea4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4ab8cc69.effex.pages.dev |
| Branch Preview URL: | https://test-navigation-popstate-cov.effex.pages.dev |
Deploying effex-api with
|
| Latest commit: |
1c29ea4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ac68117f.effex-api.pages.dev |
| Branch Preview URL: | https://test-navigation-popstate-cov.effex-api.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The existing Navigation tests mocked
window.addEventListeneras avi.fn()that captured the handler but never fired it — so nothing verified that browser back/forward actually flowed through to the pathname signal and its subscribers.Adds three regression tests (currently ALL PASSING on main):
popstate updates pathname signal— basic mechanism, verifies the ref update.popstate notifies subscribers— subscribes topathname.changesthe way Outlet does and verifies the change stream fires on popstate.popstate handler's Effect.runSync doesn't throw— captures errors thrown by the raw event dispatch and asserts none happen.Updated the mock window's
addEventListenerto store the handler so it can be dispatched via a newdispatchWindowEventhelper.Context
Locked in as regression coverage while investigating a report that browser back/forward doesn't work in SSG dev mode. The framework mechanism itself passes cleanly — issue is likely something environment-specific in the reporter's setup. These tests will catch it next time if the actual framework code regresses.
🤖 Generated with Claude Code